package uit.net.web;



import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.mobile.device.Device;
import org.springframework.mobile.device.DeviceUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class LoginController {
    
    private static final Logger LOGGER=LoggerFactory.getLogger(LoginController.class);
    
    @RequestMapping(value="/login",method=RequestMethod.GET)
    public String login(@RequestParam(value = "login_error", required = false) String loginError,ModelMap model,HttpServletRequest request,Device device)
    {
        LOGGER.debug("1. Login attemp from "+request.getRemoteAddr());
        
        Device currentDevice=DeviceUtils.getCurrentDevice(request);
        
        LOGGER.debug("2. Login attemp from "+currentDevice.isNormal());
        LOGGER.debug("3. Login attemp from "+currentDevice.isMobile());
        LOGGER.debug("4. Login attemp from "+currentDevice.isTablet());
        LOGGER.debug("exception expect: "+device.isNormal());
        return "login";
    }
    
    @RequestMapping(value="/loginfailed",method=RequestMethod.GET)
    public String loginFail(ModelMap model)
    {
        return "login";
    }
    
    @RequestMapping(value="/logout",method=RequestMethod.GET)
    public String logout(ModelMap model)
    {
        return "logout";
    }

}